<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>四川省工程建设领域项目信息、信用信息公开维护平台</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/reset.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/main.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/My97DatePicker4/WdatePicker.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery-latest.pack.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery.form.js"></script>
<script type="text/javascript">
var submitFlag = true;
function check(){
	var f = document.getElementById("form1");
	if (f.deptName.value == ""){
		alert("必须填写部门名称");
		f.deptName.focus();
		return false;
	}
	if (f.userAccount.value == ""){
		alert("必须填写帐号");
		f.userAccount.focus();
		return false;
	}
	if (f.userPassword.value == ""){
		alert("必须填写密码");
		f.userPassword.focus();
		return false;
	}
	if (f.userPassword.value.length < 4){
		alert("密码至少需要四位");
		f.userPassword.focus();
		return false;
	}
	return true;
}

function checkOrgCode(obj)
{

	if (obj.value != "")
	{
		if(obj.value.length < 9){
			var obj = document.getElementById("oCd");
			obj.innerHTML='<font color="#FF9966">该组织机构代码不正确</font>';
			return;
		}
		setTimeout(function(){checkOrgCodeDB(obj);}, 2000);
	}
}

function checkOrgCodeDB(obj)
{
	var options={type:"POST", 
				url:"<%=request.getContextPath()%>/user/orgCodeAuth?orgCode="+obj.value, 
				dataType:"json", success: checkOrgCodeHandle};
	$.ajax(options);
}

function checkOrgCodeHandle(data,status) {
	var obj = document.getElementById("oCd");
	if(status){
		if (data.result == 0){
			obj.innerHTML='<font color="#669933">该组织机构代码可以注册</font>';
		}
		else{
			obj.innerHTML='<font color="#FF9966">该组织机构代码已被注册</font>';
		}
	}
	else{
		obj.innerHTML='<font color="#FFFF00">无法检测组织机构代码</font>';
	}
}

function checkAccount(obj)
{
	if (obj.value != "")
	{
		setTimeout(function(){checkAccountDB(obj);}, 2000);
	}
}
function checkAccountDB(obj)
{
	var options={type:"POST", 
				url:"<%=request.getContextPath()%>/user/accountAuth?account="+obj.value, 
				dataType:"json", success: checkAccountHandle};
	$.ajax(options);
}
function checkAccountHandle(data,status) {
	var obj = document.getElementById("acr");
	if(status){
		if (data.result == 0){
			obj.innerHTML='<font color="#669933">本帐号可以使用</font>';
		}
		else{
			obj.innerHTML='<font color="#FF9966">本帐号已存在</font>';
		}
	}
	else{
		obj.innerHTML='<font color="#FFFF00">无法检测帐号</font>';
	}
}

function checkAccAndOrgCode(){
	var userAccount = $('#userAccount').val();
	var orgCode = $('#orgCode').val();
	submitFlag = false;
	var options={type:"POST",
			data: "userAccount="+userAccount+"&orgCode="+orgCode,
			url:"<%=request.getContextPath()%>/user/userAccountAndOrgCodeAuth", 
			dataType:"json", success: checkAccAndOrgCodeHandle};
	$.ajax(options);
}

function checkAccAndOrgCodeHandle(data,status){
	submitFlag = true;
	if(status){
		if (data.result == 0){
			document.getElementById('form1').submit();
		}
		else{
			alert(data.msg);
		}
	}
	else{
		alert('网络连接异常，请联系管理员');
	}
}

function reg(){
	if(!submitFlag){
		alert('请求已提交，请稍候');
		return;
	}
	if(!check()){
		return;
	}
	checkAccAndOrgCode();
}

function init() {
	${msg}
}
</script>
</head>
<body onload="init();">
<form method="post" name="form1" id="form1" action="<%=request.getContextPath()%>/user/depAccDealer/" >


<table class="regtable">
  <tr>
<th colspan="2">行业主管部门账号注册</th>
  </tr>
  <tr>
  <td class="w02"></td>
  <td><span style="padding-right:140px">带<b>*</b>的项为必填项</span></td>
  </tr>
  <tr>
    <td class="w02">地区</td>
    <td><input type="text" class="intt" maxlength="50" disabled="disabled" value="${areaName}"/><b>*</b><span>部门所在地区</span>
    </td>
  </tr>
  <tr>
    <td class="w02">国家部委</td>
    <td><input type="text" class="intt" maxlength="50" disabled="disabled" value="${topDeptName}"/><b>*</b><span>部门所对应的国家部委或直属机构</span></td>
  </tr>
  <tr>
    <td class="w02">部门全称</td>
    <td><input type="text" class="intt" name="deptName" maxlength="50" value="${user.deptName}"/><b>*</b><span>请输入部门名称的全称</span></td>
  </tr>
  <tr>
    <td class="w02">帐号</td>
    <td><input type="text" class="intt" id="userAccount" name="userAccount" onblur="checkAccount(this)" value="${user.userAccount}"/><b>*</b><span id="acr">用于登录的用户名</span></td>
  </tr>
  <tr>
    <td class="w02">初始密码</td>
    <td><input type="text" class="intt" name="userPassword" maxlength="6" value="${user.userPassword}"/><b>*</b><span>请区分大小写，4-6位</span></td>
  </tr>
  <tr>
    <td class="w02">地址</td>
    <td><input type="text" class="intt" name="companyAddr" maxlength="50" value="${user.companyAddr}"/><span>部门所在地详细地址</span></td>
  </tr>
  <tr>
    <td class="w02">联系人</td>
    <td><input type="text" class="intt" name="contacter" maxlength="50" value="${user.contacter}"/><span>敏感信息将不会被公开</span></td>
  </tr>
  <tr>
    <td class="w02">联系电话</td>
    <td><input type="text" class="intt" name="phone" maxlength="50" value="${user.phone}"/><span>敏感信息将不会被公开</span></td>
  </tr>
  <tr>
    <td class="w02">电子邮件</td>
    <td><input type="text" class="intt" name="email" maxlength="50" value="${user.email}"/><span>找回密码必填</span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    <input type="hidden" name="deptCode" value="${deptCode}"/>
    <input type="hidden" name="topDeptName" value="${topDeptName}"/> 
    <input type="hidden" name="areaName" value="${areaName}"/>
    <input type="hidden" name="userID" value="0"/> 
    <input type="button" value="注 册" class="btn40" onclick="reg()"/>
    <input type="button" value="返 回" class="btn40" onclick="javascript:location.href='<%=request.getContextPath()%>/monitor/accManage'"/>
    </td>
  </tr>
    <tr>
  <td colspan="2"></td>
  </tr>
</table>

</form>
</body>
</html>
